Can I use 301 redirection for included external javascript files?

I am trying to clear some files on a website, one task is to map all jquery links to a particular file.

Yes, this is a large site with several developers, and some standards were not followed, which led to the current situation when there are different versions of jquery.

What I was trying to do was create a 301 redirect for these files to point to a single version.

for example: <script type="text/javascript" src="/someurl/js/jquery-1.4.4.min.js">must point to/someurl/js/jquery-core.min.js

I tried to do this, but it did not seem to upload a new file, and jquery does not exist, my network panel shows that there are 301 in the source file, and I see a link to the new one, however the "answer" tab is empty.

Can 301 redirects be used this way?

Thanks for any suggestions / feedback.

ps I know there are better ways to link to jquery, etc., but a big company process and a red ribbon stand in my way, doing it in any other way.

+2
source share
1 answer

When the browser loads the script from the src attribute, it must follow all the redirect links, the same method it extracts html, images, style sheets, etc. So the use case you provided should work.

But since it does not work for you, you have several options to solve your problem.

fiddler - , , . , 301 , , , mime , . , , .

... mod_rewrite ( URL-), script .

+2

All Articles