[ClojureScript] ClojureScript and multi-page website
I'm working on a web site which, for various reasons, achieves its purpose best with multiple pages rather than as a single-page app. All the pages will need to share some code in common. In a plain vanilla JS environment, I could do something like this on page1.html: and something similar on page2.html (with
[ClojureScript] Re: ClojureScript and multi-page website
I think what you want are multiple Google Closure modules: http://swannodette.github.io/2015/02/23/hello-google-closure-modules/ Make a single project for all pages, place each page's entry point into a separate namespace and an independent module, and then on each html page include the common module followed by the page-specific module. The Closure (not cloJure!) compiler will work out the js dependency graph and move code among the files optimally so you only have as much javascript per page as you need. This technique also works great with websockets: have browser-thread entrypoints in their own module and websocket entry points in another module. If you make sure the websocket entry points can't reach code that uses browser objects (like document or window) everything will Just Work. On Friday, February 26, 2016 at 3:31:23 PM UTC-6, J David Eisenberg wrote: > I'm working on a web site which, for various reasons, achieves its purpose > best with multiple pages rather than as a single-page app. All the pages will > need to share some code in common. > > In a plain vanilla JS environment, I could do something like this on > page1.html: > > > > > and something similar on page2.html (with
[ClojureScript] Re: ClojureScript and multi-page website
On Friday, February 26, 2016 at 2:52:28 PM UTC-8, Francis Avila wrote: > I think what you want are multiple Google Closure modules: > http://swannodette.github.io/2015/02/23/hello-google-closure-modules/ > > Make a single project for all pages, place each page's entry point into a > separate namespace and an independent module, and then on each html page > include the common module followed by the page-specific module. The Closure > (not cloJure!) compiler will work out the js dependency graph and move code > among the files optimally so you only have as much javascript per page as you > need. > > This technique also works great with websockets: have browser-thread > entrypoints in their own module and websocket entry points in another module. > If you make sure the websocket entry points can't reach code that uses > browser objects (like document or window) everything will Just Work. Thank you; it seems that this will do what I want, and the article about it arrived JIT. :) > > On Friday, February 26, 2016 at 3:31:23 PM UTC-6, J David Eisenberg wrote: > > I'm working on a web site which, for various reasons, achieves its purpose > > best with multiple pages rather than as a single-page app. All the pages > > will need to share some code in common. > > > > In a plain vanilla JS environment, I could do something like this on > > page1.html: > > > > > > > > > > and something similar on page2.html (with
Re: [ClojureScript] Re: ClojureScript and multi-page website
Don't forget the reference documentation: https://github.com/clojure/clojurescript/wiki/Compiler-Options#modules On Fri, Feb 26, 2016 at 6:07 PM, J David Eisenberg < jdavid.eisenb...@gmail.com> wrote: > On Friday, February 26, 2016 at 2:52:28 PM UTC-8, Francis Avila wrote: > > I think what you want are multiple Google Closure modules: > http://swannodette.github.io/2015/02/23/hello-google-closure-modules/ > > > > Make a single project for all pages, place each page's entry point into > a separate namespace and an independent module, and then on each html page > include the common module followed by the page-specific module. The Closure > (not cloJure!) compiler will work out the js dependency graph and move code > among the files optimally so you only have as much javascript per page as > you need. > > > > This technique also works great with websockets: have browser-thread > entrypoints in their own module and websocket entry points in another > module. If you make sure the websocket entry points can't reach code that > uses browser objects (like document or window) everything will Just Work. > > Thank you; it seems that this will do what I want, and the article about > it arrived JIT. :) > > > > > On Friday, February 26, 2016 at 3:31:23 PM UTC-6, J David Eisenberg > wrote: > > > I'm working on a web site which, for various reasons, achieves its > purpose best with multiple pages rather than as a single-page app. All the > pages will need to share some code in common. > > > > > > In a plain vanilla JS environment, I could do something like this on > page1.html: > > > > > > > > > > > > > > > and something similar on page2.html (with
Re: [ClojureScript] Re: ClojureScript and multi-page website
And obviously when I said "websockets" above I meant "webworkers"! On Fri, Feb 26, 2016 at 7:29 PM, Francis Avila wrote: > Don't forget the reference documentation: > https://github.com/clojure/clojurescript/wiki/Compiler-Options#modules > > On Fri, Feb 26, 2016 at 6:07 PM, J David Eisenberg < > jdavid.eisenb...@gmail.com> wrote: > >> On Friday, February 26, 2016 at 2:52:28 PM UTC-8, Francis Avila wrote: >> > I think what you want are multiple Google Closure modules: >> http://swannodette.github.io/2015/02/23/hello-google-closure-modules/ >> > >> > Make a single project for all pages, place each page's entry point into >> a separate namespace and an independent module, and then on each html page >> include the common module followed by the page-specific module. The Closure >> (not cloJure!) compiler will work out the js dependency graph and move code >> among the files optimally so you only have as much javascript per page as >> you need. >> > >> > This technique also works great with websockets: have browser-thread >> entrypoints in their own module and websocket entry points in another >> module. If you make sure the websocket entry points can't reach code that >> uses browser objects (like document or window) everything will Just Work. >> >> Thank you; it seems that this will do what I want, and the article about >> it arrived JIT. :) >> >> > >> > On Friday, February 26, 2016 at 3:31:23 PM UTC-6, J David Eisenberg >> wrote: >> > > I'm working on a web site which, for various reasons, achieves its >> purpose best with multiple pages rather than as a single-page app. All the >> pages will need to share some code in common. >> > > >> > > In a plain vanilla JS environment, I could do something like this on >> page1.html: >> > > >> > > >> > > >> > > >> > > and something similar on page2.html (with
Re: [ClojureScript] Re: ClojureScript and multi-page website
On Friday, February 26, 2016 at 5:30:45 PM UTC-8, Francis Avila wrote: > And obviously when I said "websockets" above I meant "webworkers"! It works just great; thanks. Sadly, it doesn't seem to be compatible with figwheel, as figwheel requires :optimizations :none, but :modules requires :optimizations :simple > > > On Fri, Feb 26, 2016 at 7:29 PM, Francis Avila wrote: > > Don't forget the reference documentation: > https://github.com/clojure/clojurescript/wiki/Compiler-Options#modules > > > > > On Fri, Feb 26, 2016 at 6:07 PM, J David Eisenberg > wrote: > On Friday, February 26, 2016 at 2:52:28 PM UTC-8, Francis Avila wrote: > > > I think what you want are multiple Google Closure modules: > > http://swannodette.github.io/2015/02/23/hello-google-closure-modules/ > > > > > > Make a single project for all pages, place each page's entry point into a > > separate namespace and an independent module, and then on each html page > > include the common module followed by the page-specific module. The Closure > > (not cloJure!) compiler will work out the js dependency graph and move code > > among the files optimally so you only have as much javascript per page as > > you need. > > > > > > This technique also works great with websockets: have browser-thread > > entrypoints in their own module and websocket entry points in another > > module. If you make sure the websocket entry points can't reach code that > > uses browser objects (like document or window) everything will Just Work. > > > > Thank you; it seems that this will do what I want, and the article about it > arrived JIT. :) > > > > > > > > > > On Friday, February 26, 2016 at 3:31:23 PM UTC-6, J David Eisenberg wrote: > > > > I'm working on a web site which, for various reasons, achieves its > > > purpose best with multiple pages rather than as a single-page app. All > > > the pages will need to share some code in common. > > > > > > > > In a plain vanilla JS environment, I could do something like this on > > > page1.html: > > > > > > > > > > > > > > > > > > > > and something similar on page2.html (with