tag:blogger.com,1999:blog-34454975.post863919178631818896..comments2023-06-28T16:58:41.189+02:00Comments on Web Reflection: A Meaningful Client Side Alternative To node require()Andrea Giammarchihttp://www.blogger.com/profile/16277820774810688474noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-34454975.post-48472959289649726112012-09-12T02:20:30.691+02:002012-09-12T02:20:30.691+02:001 - same with anything else you are using ... you ...1 - same with anything else you are using ... you can use the require version that is not packed and produce the build so no differences with any other solution you are adopting right now ... you don't build during development<br /><br />2 - I am using smartest solution too then ... cause I have all files in my inline script but I load them synchronously, runtime, and only once, caching them, when needed. Same concept indeed with the build version for production which means, better performance. Your current approach is to load all files in memory at once, even if you don't need them. Node does not do it, neither this proposal.<br /><br />3 - performance irrelevant ... prove it on mobile or consider that Google and many others have adopted this technique of lazy evaluating because of performance. I guess we didn't just wake up thinking we improved them ... right?<br /><br />4 - no wheel reinvented here because there's no tool able to produce this proposal. None of them, but I could create some plugin for grunt I guess ... good hint<br /><br />5 - AMD allows you to load asynch then you say you don't want to load async and bring templates together, pre compiled, 'cause in your case these are few lines ... well, this does not scale plus require() modules has *nothing* to do with templates. I have no idea why AMD decided to include templates ... it seems so wrong for me I don't think I even care? Sorry but mixing templating and modules ... uhm, MVC anybody?<br /><br />Keep env clean is not a tool matter, is a developer matter.<br />With this proposal nothing is less clean except you need one script, the require one, and eventually to require the page/module you want ... that's it.<br /><br />In any case ... you really don't have to use this technique, if you are happy with AMD :)<br /><br />I like node.js module system, the API is locked as ultra stable, and nobody complained there.<br /><br />On web, nobody thought about this solution, everything included, still evaluated as modules.<br /><br />It won't be the first, neither the last one, I wrote something that in a couple of years will be widely used so, if right now it's just me ... it's OK :DAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-74496939839368892022012-09-11T22:28:18.649+02:002012-09-11T22:28:18.649+02:00Hi Andrea,
I have tested requrejs, your require pr...Hi Andrea,<br />I have tested requrejs, your require proposal and the default script include on a complex real project. Before telling you the result I should tell you that I was an AMD fan but then luckly I changed my opinion.<br /><br />1 - using requirejs or your proposal it is almost impossible for someone else to start working on a project because it is hard to have an overview about all the js modules used ( A developer should open each js file trying to understand where and when a module is included and why )<br /><br />2 - nodejs is using the require method just because it has no DOM environment in which include other modules so this is the smartest solution to solve this problem; so why then if we have already the DOM to include our modules we should do it in a different way?<br /><br />3 - requirejs and your require script are both no standard and the performance improvement is irrelevant<br /><br />4 - It could be useful to use requirejs or require_client to package our files in production but so why we should reinvent the wheel if there are smartest solutions like <a href="https://github.com/cowboy/grunt" rel="nofollow">grunt</a> or <a href="http://incident57.com/codekit/" rel="nofollow">Codekit</a> doing it as well without many ceremonies?<br /><br />5 - The AMD technology allows us to load asynchronously javascript templates and in most cases they are less then 30rd line of code so why we can not embed them directly into the page? Do we really need all these http requests?<br /><br />My win right now is to use the default script tag to emebed my modules and then to minify everything in production with Codekit, I think it is not too hard to keep the dev environment clean for a good web developer having this kind of initial asset.<br /><br />kind regards<br />Gianluca<br /><br />p.s. se dovessi passare a Zurigo mi farebbe piacere bere una birretta per approfondire queste tematiche e ovviamente sarrebbe un onore conoscerti vista la tua grande competenza cheersAnonymoushttps://www.blogger.com/profile/17709404589264777162noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-61875264272099964832012-09-11T13:15:48.205+02:002012-09-11T13:15:48.205+02:00Gianluca ... after long meditation on it ... I hav...Gianluca ... after long meditation on it ... I have decided that require() has nothing to do with templates and these two topics should be split.<br /><br />require() is about modules ... templating is another story. Another task to put in the build process, not something directly able to affect code modules logic/mechanism ... imhoAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-33747928763936555962012-09-10T15:07:09.725+02:002012-09-10T15:07:09.725+02:00so the template AMD double win is that these are n...so the template AMD double win is that these are not lazy loaded and these are precompiled ... so basically AMD is a 100% non-sense ... awesome.<br /><br />Anyway, it's a matter of defining modules able to export a pre-compiled version of the template.<br /><br />The require_client in this case should be run *after* the generic "create_templates" put file.html.js inside the same folder? ... not sure how node.js solves this ... but I'll try to provide an example or a solution that scales, cheers.Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-46597175239507197162012-09-09T11:17:09.626+02:002012-09-09T11:17:09.626+02:00Ciao Andrea,
I think you didn't understand wha...Ciao Andrea,<br />I think you didn't understand what I meant, please let me clarify my topic:<br />when we implement an AMD structure we want be able also to load and compile our HTML using javascript templates (check this out <a href="https://github.com/ZeeAgency/requirejs-tpl" rel="nofollow">requirejs-tpl</a> and <a href="http://backbonetutorials.com/organizing-backbone-using-modules/" rel="nofollow">organizing backbone using modules</a>). <br /><br />This means that we need something like this:<br /><br />require("my_javascript_library");<br />require("my_javascript_model");<br />require("my_javascript_template.html");<br /><br />Require.js solves this problem with an elegant solution:<br /><br />define([<br /> "my_javascript_library",<br /> "my_javascript_model",<br /> "text!my_javascript_template.html"<br /> ], function(lib,model,tpl) {<br /> // ok now I can compile my model having a nice js template<br />});<br /><br />I think it is not that hard to extend your script having also this feature.<br />Hoping that my previous post is more clear right now.Anonymoushttps://www.blogger.com/profile/17709404589264777162noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-25022326326036688102012-09-08T21:36:41.001+02:002012-09-08T21:36:41.001+02:00Gianluca ... whatever node JS based plugin you are...Gianluca ... whatever node JS based plugin you are talking about is automatically compatible with this implementation of require ... or maybe I did not understand what kind of "templates" you are talking about? Please tell me more, thanks :)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-10484948482539354972012-09-08T19:47:15.790+02:002012-09-08T19:47:15.790+02:00Hi Andrea,
I have tested your script (I really lik...Hi Andrea,<br />I have tested your script (I really like your idea) and it works perfectly but right now it is able to load only javascript modules and it doesn't allow us to require javascript templates (or anything else). I think that the power of require.js is in its plugins that can extend its core covering all developers needs. By the way it is a great proposal and I hope to get soon an extended version of your script.<br /><br />Bravo!Anonymoushttps://www.blogger.com/profile/17709404589264777162noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-40803094202023143742012-09-07T00:52:13.870+02:002012-09-07T00:52:13.870+02:00Daniel I don't understand your comment ... if ...Daniel I don't understand your comment ... if it's about require() VS Google Closure it's pointless 'cause Google Closure does not support CommonJS require() module syntax, neither is able to lazy evaluate compressed code.<br /><br />If it's about suggeting the usage of google closure compiler, rather than UglifyJS or YUICompressor, then it might be another alternative but imho not that needed.<br /><br />If it was about something else, please explain, thanks:)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-36014377623650779742012-09-06T22:17:27.153+02:002012-09-06T22:17:27.153+02:00Google Closure done it well.Google Closure done it well.Daniel Steigerwaldhttps://www.blogger.com/profile/14925689736283077556noreply@blogger.com