Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern
Den 03.02.2011 13:03, skrev Fran: Hi guys, I know this is more jQuery related question and perhaps it'd be better to ask in its forum but I'll drop it in case some jQuery experts in this group could answer it. Is there any reason why I should be using "$(document).bind/trigger" over "$('body').bind/trigger" (or the other way around) if I wanted to use it as a PubSub ? Any different in terms of performance or others ? Thanks Hello, maybe it's worth checking out this jQuery plugin for your pub/sub needs: https://gist.github.com/661855 -- Mads Erik Forberg -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com
Re: [JSMentors] Re: Async document.write
Hi Trygve! Thanks for the advice! I have now contacted A-pressen Digitale Medier about working together to get AdTech to provide a better solution than document.write :-) Kind regards, Mads Erik Forberg Den 19.12.2010 16:00, skrev Trygve Lie: Hi I see some using the trick by fetching ads at the bottom of a page and moving them to placeholders further up in the page. An old trick also without problems. Do note that if you move a script tag with a external reference to a JS file our beloved IE6 and IE7 will request the external JS file once more. In the case of a ad system, ads will be COUNTED TWICE due to this movement. I did run into this problem some years ago with Ad Tech ads. Here are a deeper explanation of the problem and a "solution": http://www.trygve-lie.com/blog/entry/moving_a_script_ie_might Tough; ad systems such as Ad Tech could improve a lot in how they include ads. I think the best approach in the long term are to talk to the ad companies. Some years ago my company had several discussions with Ad Tech regarding such problems. I think if several customers get together it would also be worth to joining forces to talk to the companies. Here in Norway you might be interested in talking to A- Pressen Nye Medier about this Mads. PS: There are ad companies solving this. I thing DoubleClick have a proper solution on including ads. Though, a long time since I looked at it. Trygve On Dec 16, 2:59 pm, Gregers Gram Rygg wrote: Mads: Thanks for bringing this up! Always beer at our meetups, sometimes for free ;) Steve Souders just released ControlJS a few hours ago:http://stevesouders.com/controljs/ Haven't had time to check it out yet, but looks promising! Gregers On Thu, Dec 16, 2010 at 1:58 PM, Anton Yacenko wrote: Sorry, but code gone with my leave from eBay :) I thought it's in production, but marktplaats.nl there is another solution that was pointed in this thread: load banners in the bottom and move nodes to the placeholders. Anton. On Dec 16, 2010, at 2:15 PM, Mads Erik Forberg wrote: Sounds good, can you provide a code example for this? :-) Kind regards, Mads Den 16.12.2010 10:37, skrev Anton Yacenko: I've solve this problem with document.write redefine, it's not simple solution, coz you need to control script loading, but in common was like this: redefine document.write, parse content for each dw call, find content and scripts inside put content to placeholder, async. load scripts that was found (that scripts could use dw too, so you need to redefine dw again; i've worked with doubleclick banners and sometime there was 3 scripts inside each other who called dw); this solution easy when you have 1 banner, when you have 2 and more you basically need to load all scripts by yourself and execute in needed document.write context for exactly banner placeholder, this means global redefined document.write became a proxy for all scripts and placeholders, this require more complicated "architecture" implementation. I've solve multiple banners loading with simple "text" events (basically simple observer). Erik, I hope this flow of thoughts could help you somehow :) All, interesting to hear if anyone used solution like this Regards, Anton. On Dec 15, 2010, at 11:31 PM, Ben Alman wrote: I wrote a small jQuery plugin to do this, but I didn't get to spend enough time on it to know if and when it will fail. It doesn't use Iframes, but does override document.write and document.writeln, and in my testing, worked with nested scripts. It's obviously not the most robust solution out there, since it doesn't use Iframes to sandbox. http://benalman.com/projects/jquery-misc-plugins/#loadadscript - Ben "Cowboy" Ben Alman http://benalman.com/ RJ3 Productions Broken Buddha Records On Wed, Dec 15, 2010 at 2:29 PM, Balázs Galambosi wrote: This is almost exactly the same as placing the code to the bottom of the page (without iframes) and replacing the placeholders with the real content after dom:load. The difference is that e.g. Adsense doesn't like "fake" iframes (because it's generating ads depending on the page's content). Synchronous I/O at the bottom of the page is an acceptable trade-off in my opinion. The only downside is that you need to have a good management of such scripts because you have to place the placeholder and the real ad separately depending on the current page. 2010/12/15 Nicola Rizzo: I solved this problem using iframes: after the page load my script creates an iframe for every banner, so the load time is not affected by the external scripts. The iframe's src points to a page containing the original synchronous script, wrapped in a div, ie: When the iframe's onload is fired, my handler copies the document.getElementById('wrapper').innerHTML to the main document (in a parent.document.getElementById(íframecontainer') or something
Re: [JSMentors] Async document.write
Thank you for the help and usefull links, Gregers! I will test out crapLoader, I'll give you some feedback ASAP. I've heard of it, maybe I should join up for the next meeting? Will there be beer? ;-) /Mads Den 16.12.2010 13:26, skrev Gregers Gram Rygg: Hi, Here is a list of useful resources I've found on async document.write: http://www.delicious.com/gregersrygg/document.write Haven't found a solution that fits my needs, so have started on my own implementation. The main difference from other doc.write hacks is that it can start loading the ads in the background before DOMContentLoaded, and has an option to load the ads sequentially. It's far from production ready, as there are so many unthinkable things a third-party script can do. But feel free to test if it works for you: https://github.com/gregersrygg/crapLoader What I find most difficult is not to solve specific problems, but to find them. There are so many weird things third-party or ad scripts can do. It would be really helpful if those who attempted to make document.write hacks documented their attempts. I guess we all have different needs, problems and solutions. Started on a wiki-page with problems/solutions I've found so far. Contributions are welcome: https://github.com/gregersrygg/crapLoader/wiki/What-to-think-about-when-replacing-document.write Kyle: Can you please describe the iframe problem you are describing in more detail? When does it become a problem? Friendly iframes? Cross-origin iframes don't have access to the document, so that should work as a black box, or not? Mads: have you heard about the front-end (mostly js) user group in Oslo? http://www.meetup.com/framsia/ Regards, Gregers -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com
Re: [JSMentors] Async document.write
Sounds good, can you provide a code example for this? :-) Kind regards, Mads Den 16.12.2010 10:37, skrev Anton Yacenko: I've solve this problem with document.write redefine, it's not simple solution, coz you need to control script loading, but in common was like this: redefine document.write, parse content for each dw call, find content and scripts inside put content to placeholder, async. load scripts that was found (that scripts could use dw too, so you need to redefine dw again; i've worked with doubleclick banners and sometime there was 3 scripts inside each other who called dw); this solution easy when you have 1 banner, when you have 2 and more you basically need to load all scripts by yourself and execute in needed document.write context for exactly banner placeholder, this means global redefined document.write became a proxy for all scripts and placeholders, this require more complicated "architecture" implementation. I've solve multiple banners loading with simple "text" events (basically simple observer). Erik, I hope this flow of thoughts could help you somehow :) All, interesting to hear if anyone used solution like this Regards, Anton. On Dec 15, 2010, at 11:31 PM, Ben Alman wrote: I wrote a small jQuery plugin to do this, but I didn't get to spend enough time on it to know if and when it will fail. It doesn't use Iframes, but does override document.write and document.writeln, and in my testing, worked with nested scripts. It's obviously not the most robust solution out there, since it doesn't use Iframes to sandbox. http://benalman.com/projects/jquery-misc-plugins/#loadadscript - Ben "Cowboy" Ben Alman http://benalman.com/ RJ3 Productions Broken Buddha Records On Wed, Dec 15, 2010 at 2:29 PM, Balázs Galambosi mailto:galambal...@gmail.com>> wrote: This is almost exactly the same as placing the code to the bottom of the page (without iframes) and replacing the placeholders with the real content after dom:load. The difference is that e.g. Adsense doesn't like "fake" iframes (because it's generating ads depending on the page's content). Synchronous I/O at the bottom of the page is an acceptable trade-off in my opinion. The only downside is that you need to have a good management of such scripts because you have to place the placeholder and the real ad separately depending on the current page. 2010/12/15 Nicola Rizzo mailto:nicola.ri...@gmail.com>>: > I solved this problem using iframes: after the page load my script > creates an iframe for every banner, so the load time is not affected > by the external scripts. > The iframe's src points to a page containing the original synchronous > script, wrapped in a div, ie: > > src='<a rel="nofollow" href="http://external/sync/script.js">http://external/sync/script.js</a>'> > > When the iframe's onload is fired, my handler copies the > document.getElementById('wrapper').innerHTML to the main document (in > a parent.document.getElementById(íframecontainer') or something like > that). > Hope this helps, >Nicola > > On Wed, Dec 15, 2010 at 5:26 PM, Mads Erik Forberg mailto:m...@hardware.no>> wrote: >> Hello, >> have any of you worked out a async document.write that works with >> ad-hosting-services? >> My employer uses AdTech, and some times they load ads from yet another >> ad-hosting-service, so we get many layers of document.write >> >> It works fine for the first ad-service to do this stuff: >> [code] >> var oldWrite = document.write, >> content = ''; >> document.write = function(d) { >>content += d; >> } >> [/code] >> >> But when the script from the AdTech loads, it loads yet another script that >> uses document.write from another service. And that document.write goes back >> to its old self. >> Like this: >> Initial call: >> >> In that script its: >> document.write("
Re: [JSMentors] Async document.write
Your now famous in cold and snowy Norway, thumbs up for that one! /Mads Den 15.12.2010 17:48, skrev Getify: Doug Crockford is famous for saying "IE6 Must Die!" in his presentations. I always now have a slide in my presentations that says "document.write() Must Die!". --Kyle *From:* Mads Erik Forberg <mailto:m...@hardware.no> *Sent:* Wednesday, December 15, 2010 10:44 AM *To:* jsmentors@googlegroups.com <mailto:jsmentors@googlegroups.com> *Cc:* Jason Persampieri <mailto:ja...@persampieri.net> *Subject:* Re: [JSMentors] Async document.write Den 15.12.2010 17:35, skrev Jason Persampieri: On Wed, Dec 15, 2010 at 8:26 AM, Mads Erik Forberg <mailto:m...@hardware.no>> wrote: Hello, have any of you worked out a async document.write that works with ad-hosting-services? My employer uses AdTech, and some times they load ads from yet another ad-hosting-service, so we get many layers of document.write Steve Souders (web perf guy at Google) has been on a mission to solve this problem... but unfortunately, I don't think there's currently a hack-y way to fix it? Check out http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/ for a description of his proposed FRAG tag. _jason -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com Something like that would be awesome! The problem with document.write is also when changing the ads on AJAX-loaded pages :\ Burn, document.write, burn! /mads -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com
Re: [JSMentors] Async document.write
Den 15.12.2010 17:35, skrev Jason Persampieri: On Wed, Dec 15, 2010 at 8:26 AM, Mads Erik Forberg <mailto:m...@hardware.no>> wrote: Hello, have any of you worked out a async document.write that works with ad-hosting-services? My employer uses AdTech, and some times they load ads from yet another ad-hosting-service, so we get many layers of document.write Steve Souders (web perf guy at Google) has been on a mission to solve this problem... but unfortunately, I don't think there's currently a hack-y way to fix it? Check out http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/ for a description of his proposed FRAG tag. _jason -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com Something like that would be awesome! The problem with document.write is also when changing the ads on AJAX-loaded pages :\ Burn, document.write, burn! /mads -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com
Re: [JSMentors] Async document.write
Yes, I have tried many different takes. But most of the times I land on printing the ads out on the bottom of the page, and then place them out the positions the ads are supposed to be printed. And I really don't like that solution. /Mads Den 15.12.2010 17:34, skrev Getify: ?Many have tried this. Most have failed. It's a much harder problem than it seems on the surface. What you're seeing is probably that inside an iframe, a new "window" object is created, meaning that document.write() reverts to pristine. If that iframe is on a different domain (it often is), there's almost nothing you can do to change this. And even if it's a local domain, it's still really complicated to do cross-browser. Also, keep in mind, several of the ad companies (like Google Ad-Words) have explicit wording in their TOS that forbids such activities. I've never delved much into this simply because I don't want to run afoul of such wording and have my account canceled. Just some food for thought. --Kyle ------ From: "Mads Erik Forberg" Sent: Wednesday, December 15, 2010 10:26 AM To: Subject: [JSMentors] Async document.write Hello, have any of you worked out a async document.write that works with ad-hosting-services? My employer uses AdTech, and some times they load ads from yet another ad-hosting-service, so we get many layers of document.write It works fine for the first ad-service to do this stuff: [code] var oldWrite = document.write, content = ''; document.write = function(d) { content += d; } [/code] But when the script from the AdTech loads, it loads yet another script that uses document.write from another service. And that document.write goes back to its old self. Like this: Initial call: In that script its: document.write("
[JSMentors] Async document.write
Hello, have any of you worked out a async document.write that works with ad-hosting-services? My employer uses AdTech, and some times they load ads from yet another ad-hosting-service, so we get many layers of document.write It works fine for the first ad-service to do this stuff: [code] var oldWrite = document.write, content = ''; document.write = function(d) { content += d; } [/code] But when the script from the AdTech loads, it loads yet another script that uses document.write from another service. And that document.write goes back to its old self. Like this: Initial call: In that script its: document.write("
Re: [JSMentors] Introductions
Hello, my name is Mads Erik Forberg. I'm a Norwegian frontend developer for the Norwegian technology niches at the Norwegian media group Edda Media (www.eddamedia.no), owned by Mecom Group plc (www.mecom.com). As of January the 1st 2011 I will be a part of the new digital cooperation between another Norwegian media group A-pressen (www.apressen.no) and Edda Media called Mediehuset Tek AS. Mostly I work with HTML, CSS, JavaScript, PHP and some Linux system administraion. I also have the technical responsibility for the forum board www.diskusjon.no. In most of my work I use the jQuery and dojo JS libs. My personal website is www.forberg.nu and my personal Twitter account is: http://twitter.com/forberg Kind regards, Mads Erik Forberg Den 14.12.2010 02:13, skrev inimino: Hi all, Now that the mailing list is working reliably, I thought I might start an introductions thread. Please reply if you want to introduce yourself to the list and say something about your interest in JavaScript. I'm using JavaScript in the browser, and on the server with node.js, which I really enjoy. I have a blog: http://inimino.org/~inimino/blog where I rarely post, but usually about something JavaScript-related. The most interesting JavaScript project I'm involved in at the moment is probably a parser generator called PanPG, which has been a lot of fun: http://boshi.inimino.org/3box/PanPG/about.html PanPG includes a JavaScript parser and I have a couple tools that are almost usable for doing interesting things with JavaScript source code. I also am working on a toy Scheme implementation in JavaScript as part of my progress through the classic book SICP: http://boshi.inimino.org/3box/inimino/projects/SICP/chap_5/Ex51/src/test.html Scheme and JavaScript are very closely related languages, with some notable differences (tail call optimization, call/cc, macros) so it's been quite interesting to implement one in the other; of course I've learned a lot about Scheme by implementing it, but also a few things about JavaScript. -inimino -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com