I have look everywhere for an answer for this and cannot find an answer. Just to be clear, i am not asking how to minify js but specifically the Google Optimise js files which are 3rd party.
We use "Google Optimize" for a/b testing etc which we load in through Google Tag Manager.
Does anyone know how to minify the "Google Optimize" javascript as we always get marked down on PageInsights for it?
The only way I can think of that lets you minify it without adding overhead to each request is to cache and minify locally and serve it from your own server.
So write a back-end script that downloads the script every hour or so, minifies it and then caches that version at some URL.
Then instead of loading the script from Google CDN you serve it from your own CDN / server.
Related
You can find meaning of code busting at https://www.keycdn.com/support/what-is-cache-busting
The main point is that when new version is deployed, uses should use new feature with avoiding cache feature.
My app is deployed with Universal SSR and using scss.
I checked deployed files and css codes was included at html so css is not related to cache busting.
Also, I checked js file and whenever the js file is builed, the filename seems changed with some random string. I think it support cache busting on js file.
My conclusion is that nuxt support cache busting. Am I right? If then, Can you give proper reference on nuxt website or webpack configuration codes on github??
Thank you!
I have a simple Joomla-website.
I want to create a copy of my website but it will be composed only from HTML/CSS/Javascript files (no PHP files, database, ...) because I want visit my website without Internet. Only HTML/CSS/Javascript files.
Is it possible? If yes, how?
Thanks
It can be done, using the same logic as generated cache works, saving the html result pages processed by php.
You can find 2 ways to do it:
Coding: Using an web scraper . You can find good Node.js npm packages for it;
Using a 3rd Party software. Google for it.
I understand for assets like images, there is a src associated with them, which means that a browser will check the expiration date of that asset before making a new request for that asset at the src to download that asset again and then render it onto the page. How does this work with a script or module such as React? If it is a CDN, does the browser first download the script and then run it the very first time it encounters the script? And then every time after that when it needs this script again, does it just load it from its cached (instead of downloading it again from the source) and running it? Is this the same thing that happens if you have React as a node module?
This is a very large topic, the basic answer is that browsers will cache assets how you tell them too. You mention that images have expiration dates, these dates are set in HTTP headers sent by the server. You can set the same headers for javascript and any other files you request from a server and the browser will cache them the same way.
After a javascript asset is fetched (from the server or the cache), the browser parses and runs your javascript.
Node modules live in node land. Usually, before you can use code in node_modules in the browser you run it through a tool like webpack or browersify. These tools bundles ALL the code (your application + react + whatever else) into one file (usually), which is then served to browser. The browser doesn't know anything about node_modules. It just parses and runs the javascript you provided.
The one bundled file is cached based on the headers it was sent with. A CDN is (basically) just a special server optimized in serving assets quickly.
I am making a website in Codeigniter and not using any client side framework like angularJS. However I need some features of angularJS like downloading the JS and CSS once at the client rather than downloading it for each page. As my website content is much dependent on the server, should I use angularJS? I read that it makes tha application slower.
your question is not about angular at all!
I recommend you to read something about build systems like require, grunt, yeoman...
What you want to do is ajaxifying your website, as Stever said it's not about angular at all..
you may use RequireJS to load the script when a page need it.
For a best perfomance, use grunt for running any task like : minifying, compressing your stylesheet and so on..
Is Google AJAX Libraries API offering a way to serve framework file in minimize way?
The libraries themselves are served minified by default.
Unfortunately, Google does not serve gzipped versions.
If not, and if I get what you're asking, you could minify the JS yourself.