Skip to content Skip to sidebar Skip to footer

Can I Use A 301 Redirect For Included External Javascript Files?

I am trying to clean up some files on a website, one task being to collate all references to jquery to a singular file. Yes, it's a large site with multiple developers and some sta

Solution 1:

When a browser loads the script from the src attribute, it should follow all redirection links, in the same method it retrieves html, images, stylesheets, etc. So the use case you've provided should work.

But since it's not working for you, you have got a couple options to resolve your problem.

Use fiddler or a similar debugging proxy to see what's going on between your browser and the server. Perhaps the 301 is malformed, or perhaps the mime-type is misconfigured, it could be any number of things. Troubleshoot it the same way you'd troubleshoot any other issue where the browser isn't following redirects.

Or... instead of using redirects, you can use mod_rewrite (or a similar server-side URL rewriting tool) to modify the request for a particular version of a script to your canonical version.

Post a Comment for "Can I Use A 301 Redirect For Included External Javascript Files?"