Timeline for Is obtrusive JavaScript ever ok?
Current License: CC BY-SA 2.5
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 10, 2014 at 3:07 | history | made wiki | Post Made Community Wiki by Erik Reppen | ||
Jan 31, 2011 at 13:00 | comment | added | Marcie | @Petah, do you have one enormous JS file for your whole site, and everything goes in there? I have roughly one JS file per page, and that works well for me. Truly "common" stuff is all that goes in the shared JS file. | |
Jan 31, 2011 at 9:18 | comment | added | Petah | @Marcie, well I have been doing unobtrusive the entire time I have been in web development. But recently I have been asking myself, why am I putting all this JS code in a single file when it is only required for one page. If I put it on the only page that requires it, it lightens the load for everyone that doesn't need that page, and its right there when I need to modify that page, I don't have to search through 1000s of lines to find a function. | |
Jan 29, 2011 at 14:21 | comment | added | Marcie | @Petah, there are other reasons to avoid mixing JS and HTML. It's the same reasons we avoid mixing styles and HTML -- separation of concerns. If your style is mixed with your structure, which is mixed with your behavior, you have something very difficult to maintain. After doing it the "unobtrusive" way for a while, you'll see how elegant your files are, and how much easier it is to make changes. | |
Jan 29, 2011 at 12:49 | comment | added | Petah | We have a very slim target audience, and we can tell our target audience what browser and plugins/functionality they are required to have. So you my question is, is mixing JS and HTML alright in that case. Like using onclick attributes. | |
Jan 29, 2011 at 12:44 | comment | added | Marcie | @Petah, well, that's not great either. You don't want to bounce users without Javascript. So is what you're asking then, since I am kicking out the users without Javascript, is can I put the JS in the same file with my HTML? | |
Jan 29, 2011 at 12:39 | comment | added | Petah | What I'm saying is none of users have JavaScript disabled. If they do, they cant access the site. | |
Jan 29, 2011 at 12:28 | history | answered | Marcie | CC BY-SA 2.5 |