0

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

Mohammad Efazati
  • 4,812
  • 2
  • 35
  • 50
  • Why not just run this server locally? It makes for much faster development. – Ry- Jun 20 '12 at 03:21
  • Sounds like you have lots of JavaScript and every time you make a small change, everything have to be reloaded. I suggest you break up your JavaScript into smaller files to reduce the need to reload everything. – Ray Cheng Jun 20 '12 at 03:39
  • @RayCheng i have many small file and i must have all of them to can see page. now how this can be help me to reduce load? tnx for your ans – Mohammad Efazati Jun 20 '12 at 03:46

4 Answers4

1

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. :)

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
  • did you ever seen some thing after save file do this things? – Mohammad Efazati Jun 20 '12 at 03:34
  • See, actually for this to reflect, what I do is, I encapsulate all the code inside the `$(document).ready();` function. And when I add it dynamically, for every 10 seconds, I refresh the code using the method you said, but I use `?567465468` « The timestamp. Then I call the `$(document).ready();` function. I am using the code in my application for live notifications. :) – Praveen Kumar Purushothaman Jun 20 '12 at 03:37
1

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

Mohammad Efazati
  • 4,812
  • 2
  • 35
  • 50
0

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.

Community
  • 1
  • 1
Ryan
  • 2,755
  • 16
  • 30
0
<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.

Myd
  • 103
  • 6