Mohammad Efazati
Mohammad Efazati

Reputation: 4910

only change edited javascript file in browser

I have heavy project with javascript and everytime i change one file i must refresh page and all file must get again from server and my handlebar render again and ...

how i can only change edited file in browser? and not touch other files?

i don't know, some thing like append new script to page with new rev to make it not cache

<script type="text/javascript" src="/static/js/bjs/framework/manifest.js?rev=1024"></script>

also i use Mercurial, Emacs, Firefox and there is no force for this tools. only i want know this can be happen. i find way to port to my tools

some things like CSS Reloader :: Add-ons for Firefox -> https://addons.mozilla.org/en-US/firefox/addon/css-reloader/ for js and only edited js

ps: its local server but i have about 2mb file and after 10 or 20 time refresh my firefox come near crash

Upvotes: 0

Views: 192

Answers (4)

Mohammad Efazati
Mohammad Efazati

Reputation: 4910

I found somethings helpfull to answer my question

with this plugin i can find some file changed. so i can run js script after change file and replace js file with new file. i thinks this is best way for developing

Upvotes: 1

Myd
Myd

Reputation: 103

<script tyep="text/javascript">

</script>

<script tyep="text/javascript">
 document.scripts[0].src="/static/js/bjs/framework/manifest.js?rev="+Math.random()
</script>

use Math.random() function get new rev everytime.

Upvotes: 0

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167162

For a particular interval, you can refresh the JavaScript Code using setInterval() and reload it again.

<script type="text/javascript">
    var sc = document.createElement('script');
    setInterval('sc.setAttribute("src", "script.js")', 5000);
</script>

Hope this helps or gives you an idea of what you need to do. :)

Upvotes: 1

Ryan
Ryan

Reputation: 2815

In Firebug, you can edit your js/css files on the fly, and/or using the javascript console, run code without refreshing the page. That is the only thing I could think of that might help. Take a look here How to edit JavaScript in Firebug? to see how.

Upvotes: 0

Related Questions