简体   繁体   中英

Hiding a script src on the page?

Is there any option to hide script source?

<script src="./script/jquery/jquery-X.X.X.js" type="text/javascript"></script>

delete this value or change to

<script src="./script/jquery/jquery" type="text/javascript"></script>

without changing a file name in the project?

No there isn't - the browser always needs to know the script is there to be able to use it. Tools baked into every modern browser make it trivial to see all scripts, no matter how hard they have been obfuscated. But maybe I have mis-understood your question - are you just trying to hide the path of your file?

You could use mod_rewrite (if using Apache webserver) to map one url to another in the .htaccess file:

RewriteEngine on
RewriteRule ^/script/jquery/jquery$ /script/jquery/jquery-1.2.3.js [NC,L]

Not sure what kind of feature that would be though. I can't see any benefit of doing so. One can always inspect any asset downloaded along with the page.

The only "protection" there is would be to build entire app into one bundle file (using Webpack for example) and then obfuscate the code. But there are plenty of deobfuscation tools already, available online. So no, you can't protect front assets.

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