When I update and reset my web project, client browser were unable get the newest js files.
So how to solve this problem.
I will appreciate that you can give me some advice
First, check your js file had updated in tomcat.
if the file is newest in tomcat.
The reason is the broswer cache.try to clear the brower cache.
If you use chrome,you can try this:
I usually use a chrome plugin to clear cache,The plugin named Clear Cache,you can find this plugin in chrome webstore.
or load js file like below
<script>
document.write("<script type='text/javascript' src='/js/test.js?"+Math.random();+"'></script>");
</script>
Related
I'm trying to find how where and how to upload my scripts where I can source them as an external script.
I can't seem to find any question like this or maybe I'm not good enough in searching
But anyway, my situation is, I need to upload script online, a basic document.write to save space.
It cannot be a file on the same folder of storage as my pages because it's for work, and pages should be shareable to people as a standalone file so they don't have to extract it anymore.
Now I have tried to upload it online on different types of cloud or host, but I can't source it, because of security purposes I think?
Or maybe the source tag I should use must be different if it's online?
is it not <script type="text/javascript" src="https://abc.blabla.com/files/includes/html/page-links.js"></script>
Please please help. The main goal I have here is to upload my scripts online, and be able to source it as an external script on my "static and local website"
Thank you,
Renz
You probably are getting into to issues in most browsers when trying to load javascript from one domain (your-website.com) to another (localhost).
https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
You can try loading your browser with CORS disabled (Chrome):
Disable same origin policy in Chrome
Or with a plugin such as these:
https://chrome.google.com/webstore/search/cors
You can do static hosting in firebase. once you host the files there then you can use the file link in script tag.
<script src="https://test.firebaseapp.com/file.js" ></script>
I'm working on a Laravel app and made updates to a JavaScript file. As I test the updates, I notice that it was not working. I opened the browser (Google Chrome) Developer Tools and checked the JavaScript file (under Sources). I noticed that it still has the old code.
Is there any cached file being created that I need to update as well?
I'm using Laravel ver 4
This is probably the local cache from your browser. You can fix this by adding a version number or hash to the url of your javascript file.
For example:
<script src="/js/app.js"></script>
Becomes:
<script src="/js/app.js?1234"></script>
This way your browser will see the file as a new resource and not use the existing cache.
My problem is when I edit my previous javascript or css file link to my html file, the function/code that I add are not functioning even I delete the whole code in my js file. The previous code only is functioning.
It might be your cache were not deleted ,that's why it still using your previous javascript file.
To fix that:
Empty your cache
(In GoogleChrome ) Open developer tools( or press F12 ) then You can right click on
refresh and select Empty Cache and Hard Reload
Your updated javascript now will be loaded.
CLEAR GOOGLE CHROME CACHE
CLEAR FIREFOX CACHE
CLEAR INTERNET EXPLORER CACHE
What server software are you hosting with? Apache? Express/node?
I noticed depending on how I configured something like forever or nodemon to host my express sites, it did not reflect changes when not using grunt. I had to restart them to get them to use the newly changed files.
Did you use a Yeoman generator?
My code of sliding menu is not working in the project although i tested it on jsfiddle it is working there fine but it is not working in my project .actually the problem is in inclusion of file " jquery-1.11.2.min.js" i have also downloaded this file and included in my project and provided a path for the same but still it is not working this is the code for including the file am i doing anything wrong for including that file
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
this is the path in the directory of my project
<script type="text/javascript" src="../scripts/jquery-1.11.2.min.js"></script>
When using a Library like jQuery, it's highly recommended for performances purposes to use a link from the Google Hosted Libraries.
For Jquery 1.11.2, it's :
https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
Why ? Because a lot of website import libraries from this link, so it's in the user local cache, and it will be load from local almost each time.
yes it shows error GET file://
When run locally src="// would default to the local file:// protocol which will not work.
Use src="https://code.jquery.com/jquery-1.11.2.min.js"
I am facing JavaScript problems on XAMPP Localhost. The Collapse Buttons, go to top button and jQuery news feed are not working on every site on my localhost.
But Facebook, Twitter, Plusone buttons load correctly from remote server i.e. from the respective Social Sites.
So, I think it narrows me to the point that the JavaScript files hosted locally are not executed while those from Facebook etc. are getting executed.
I tried reinstalling XAMPP but didn't work.
I know this is old but, I had the same problem and found this question while searching a solution. But I have lampp installed on ubuntu and since Linux asks permission to execute ANYTHING, the local js files which resided in htdocs were without permission. After:
sudo chmod 777 -R /opt/lampp/htdocs
... everything was OK. Hope this helps future wanabee web developers.
It should not matter whether your files are local or not...javascript should still get executed. Try using some debugging tool like to see if you get any errors that only occur on your local machine. Because it could be that you are running some code that is depending on a domain or whatever.
I know this post is old and the answer is already given, I just wanted to give an answer of a possible reason that I encountered in case someone else finds this and it does not help.
Make sure your entire html code gets executed by viewing your page source. With me, half my code was not being executed due to a PHP error that was working on localhost with the local database but not on live with the live database. This caused the HTML to cut of from that point above my javascript.
So check your page source. If it is being cut of somewhere, find out why :)
I had the same problem. I try a lot but finally solved. The main problem was my browser cache that prevents from loading the new JavaScript file. My recommendation is that clear your browser cache data then close the browser and reopen your site again it will work perfectly.
remove any (pre in post ) blank spaces from filenames of your namespace example : localhost:port/dir /index.html
localhost:port/dir/index.html
In similar cases,
If web project site runs JS on Live Server but not on locally opened index.html,
try to check validity of HTML File Paths,
e.g you may have written:
<script src="script.js"></script>
instead of:
<script src="./script.js"></script>
Try to add ./ before file name.
./ means Current directory.