简体   繁体   中英

Cache .js and .css files using Google chrome api

I use a website which has a very high response time. Most of the time is taken to load a page with its javascript and css files.

I want to write a Google Chrome extension which can save/cache all the js files for a really long time.

I know JS on its own would not provide me this feature. Does google chrome have an api to do the same?

Are there any other options ?

It doesn't sound like a good idea

  • Do you expect people to install this extension, for the sole purpose of visiting your site? I visit hundreds of sites regularly, should I install hundreds of extensions?
  • Will you also make an extension for Firefox / Opéra / Safari / whatever browser I like?

If the webserver correctly places the HTTP headers, the browser (Chrome and all others) will cache all resources correctly.

See How can I improve loading times on a static HTML site?

Edit : Now that I better understand your need, what you can do is create an extension that

  • is applied on the site in question
  • removes the script/css loading, for instance $('head>stylesheet').remove()
  • injects the same script/css with a local copy, and optionally improves the loading of script with $(document).ready(main_function) (rather than <body.onload="main_function()"> )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM