Re: Minimizing the download of js code in Multipage ClojureScript webapp

2013-01-28 Thread Marcus Holst
Thanks for the tip, Mimmo!


On Sunday, January 27, 2013 11:33:46 PM UTC+1, Mimmo Cosenza wrote:

 Hi Marcus, I found the same solution Evan suggested to you. You can read 
 about it here.

 https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-06.md

 and you can also define a single init function which is shared by each 
 source cljs files by passing it the parameters you need to setup each html 
 page differently. (A kind of abstraction to apply the DRY principle).

 Mimmo
  
 On Jan 27, 2013, at 10:03 PM, Marcus Holst holst@gmail.comjavascript: 
 wrote:

 Thanks Evan!
 I actually already started along this big js blob path and was just 
 beginning to see the problem with clashing page inits. Your solution with 
 an init func per page will probably do just fine for me too so I'll try 
 that now. With conditional caching on the big js file, it should only need 
 to be loaded once per site release, so it should also be ok.



 On Sunday, January 27, 2013 9:37:32 PM UTC+1, Evan Mezeske wrote:

 I solved this problem for my web app in a different way, which might be 
 worth considering.  My entire ClojureScript project compiles to a single JS 
 file which is used by every single page.  I organized things such that each 
 page had a cljs namespace associated with it, which has an init function. 
  So for instance, /foo/bar.html would know to call (myapp.foo.bar/init) 
 on load, and /baz/hello/world.html would call 
 (myapp.baz.hello.world/init) on load.  This is just one way to organize 
 things, but it works pretty well for me.

 The advantage of this approach is that you only have to download the 
 giant ball of JS once, and then it's cached for as long as you like.

 The disadvantage of this approach is that the giant ball is, well, pretty 
 giant.  I think that it makes sense to use the single JS file for 
 reasonably complex apps, where your application code is small in comparison 
 to the ClojureScript standard library.  In that case, the whole JS file 
 will not be much bigger than just the standard library itself.  Of course, 
 if your app is very large (several tens of thousands of lines of code), and 
 you really need to get the initial JS size down, you will have to do 
 something more sophisticated.

 On Sunday, January 27, 2013 4:54:59 AM UTC-8, Marcus Holst wrote:

 Building a traditional multipage webapp and using only some cljs code on 
 the pages requires me to put all the cljs overhead output in one single 
 file that can be cached by the browser (in order to not have to load the 
 same 130+ k cljs overhead for each page). I've tried creating an empty 
 namespace containing only the overhead compilation, and then requiring it 
 from one of my page specific cljs files. However this just spits out 
 endless amounts of warnings. Have anyone done this before?


 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
  
  




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en




Minimizing the download of js code in Multipage ClojureScript webapp

2013-01-27 Thread Marcus Holst
Building a traditional multipage webapp and using only some cljs code on 
the pages requires me to put all the cljs overhead output in one single 
file that can be cached by the browser (in order to not have to load the 
same 130+ k cljs overhead for each page). I've tried creating an empty 
namespace containing only the overhead compilation, and then requiring it 
from one of my page specific cljs files. However this just spits out 
endless amounts of warnings. Have anyone done this before?

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en




Re: Minimizing the download of js code in Multipage ClojureScript webapp

2013-01-27 Thread Evan Mezeske
I solved this problem for my web app in a different way, which might be 
worth considering.  My entire ClojureScript project compiles to a single JS 
file which is used by every single page.  I organized things such that each 
page had a cljs namespace associated with it, which has an init function. 
 So for instance, /foo/bar.html would know to call (myapp.foo.bar/init) 
on load, and /baz/hello/world.html would call 
(myapp.baz.hello.world/init) on load.  This is just one way to organize 
things, but it works pretty well for me.

The advantage of this approach is that you only have to download the giant 
ball of JS once, and then it's cached for as long as you like.

The disadvantage of this approach is that the giant ball is, well, pretty 
giant.  I think that it makes sense to use the single JS file for 
reasonably complex apps, where your application code is small in comparison 
to the ClojureScript standard library.  In that case, the whole JS file 
will not be much bigger than just the standard library itself.  Of course, 
if your app is very large (several tens of thousands of lines of code), and 
you really need to get the initial JS size down, you will have to do 
something more sophisticated.

On Sunday, January 27, 2013 4:54:59 AM UTC-8, Marcus Holst wrote:

 Building a traditional multipage webapp and using only some cljs code on 
 the pages requires me to put all the cljs overhead output in one single 
 file that can be cached by the browser (in order to not have to load the 
 same 130+ k cljs overhead for each page). I've tried creating an empty 
 namespace containing only the overhead compilation, and then requiring it 
 from one of my page specific cljs files. However this just spits out 
 endless amounts of warnings. Have anyone done this before?



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en




Re: Minimizing the download of js code in Multipage ClojureScript webapp

2013-01-27 Thread Marcus Holst
Thanks Evan!
I actually already started along this big js blob path and was just 
beginning to see the problem with clashing page inits. Your solution with 
an init func per page will probably do just fine for me too so I'll try 
that now. With conditional caching on the big js file, it should only need 
to be loaded once per site release, so it should also be ok.



On Sunday, January 27, 2013 9:37:32 PM UTC+1, Evan Mezeske wrote:

 I solved this problem for my web app in a different way, which might be 
 worth considering.  My entire ClojureScript project compiles to a single JS 
 file which is used by every single page.  I organized things such that each 
 page had a cljs namespace associated with it, which has an init function. 
  So for instance, /foo/bar.html would know to call (myapp.foo.bar/init) 
 on load, and /baz/hello/world.html would call 
 (myapp.baz.hello.world/init) on load.  This is just one way to organize 
 things, but it works pretty well for me.

 The advantage of this approach is that you only have to download the giant 
 ball of JS once, and then it's cached for as long as you like.

 The disadvantage of this approach is that the giant ball is, well, pretty 
 giant.  I think that it makes sense to use the single JS file for 
 reasonably complex apps, where your application code is small in comparison 
 to the ClojureScript standard library.  In that case, the whole JS file 
 will not be much bigger than just the standard library itself.  Of course, 
 if your app is very large (several tens of thousands of lines of code), and 
 you really need to get the initial JS size down, you will have to do 
 something more sophisticated.

 On Sunday, January 27, 2013 4:54:59 AM UTC-8, Marcus Holst wrote:

 Building a traditional multipage webapp and using only some cljs code on 
 the pages requires me to put all the cljs overhead output in one single 
 file that can be cached by the browser (in order to not have to load the 
 same 130+ k cljs overhead for each page). I've tried creating an empty 
 namespace containing only the overhead compilation, and then requiring it 
 from one of my page specific cljs files. However this just spits out 
 endless amounts of warnings. Have anyone done this before?



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en




Re: Minimizing the download of js code in Multipage ClojureScript webapp

2013-01-27 Thread Mimmo Cosenza
Hi Marcus, I found the same solution Evan suggested to you. You can read about 
it here.

https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-06.md

and you can also define a single init function which is shared by each source 
cljs files by passing it the parameters you need to setup each html page 
differently. (A kind of abstraction to apply the DRY principle).

Mimmo
 
On Jan 27, 2013, at 10:03 PM, Marcus Holst holst.mar...@gmail.com wrote:

 Thanks Evan!
 I actually already started along this big js blob path and was just beginning 
 to see the problem with clashing page inits. Your solution with an init func 
 per page will probably do just fine for me too so I'll try that now. With 
 conditional caching on the big js file, it should only need to be loaded once 
 per site release, so it should also be ok.
 
 
 
 On Sunday, January 27, 2013 9:37:32 PM UTC+1, Evan Mezeske wrote:
 I solved this problem for my web app in a different way, which might be worth 
 considering.  My entire ClojureScript project compiles to a single JS file 
 which is used by every single page.  I organized things such that each page 
 had a cljs namespace associated with it, which has an init function.  So 
 for instance, /foo/bar.html would know to call (myapp.foo.bar/init) on 
 load, and /baz/hello/world.html would call (myapp.baz.hello.world/init) on 
 load.  This is just one way to organize things, but it works pretty well for 
 me.
 
 The advantage of this approach is that you only have to download the giant 
 ball of JS once, and then it's cached for as long as you like.
 
 The disadvantage of this approach is that the giant ball is, well, pretty 
 giant.  I think that it makes sense to use the single JS file for reasonably 
 complex apps, where your application code is small in comparison to the 
 ClojureScript standard library.  In that case, the whole JS file will not be 
 much bigger than just the standard library itself.  Of course, if your app is 
 very large (several tens of thousands of lines of code), and you really need 
 to get the initial JS size down, you will have to do something more 
 sophisticated.
 
 On Sunday, January 27, 2013 4:54:59 AM UTC-8, Marcus Holst wrote:
 Building a traditional multipage webapp and using only some cljs code on the 
 pages requires me to put all the cljs overhead output in one single file that 
 can be cached by the browser (in order to not have to load the same 130+ k 
 cljs overhead for each page). I've tried creating an empty namespace 
 containing only the overhead compilation, and then requiring it from one of 
 my page specific cljs files. However this just spits out endless amounts of 
 warnings. Have anyone done this before?
 
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
  
  

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en