RE: Help me with my new website!
December 21, 2018 at 7:00 pm
(This post was last modified: December 21, 2018 at 7:00 pm by bennyboy.)
(December 21, 2018 at 1:50 pm)FlatAssembler Wrote:I'm not as extreme as that, either. Unless it's re-usable, I will usually put my javascript in <script> blocks on the page. I usually keep .css separate. And certain inline styles, like block behavior or word-wrap, are fine, too.Quote:But because I've programmed the site properly, I will be able to make changes to my (very large) site relatively easily.Ah, you make it sound so easy. Yes, not using too much inline CSS does solve some problems. But it doesn't do miracles.
The CSS "calc" function resolves many instances where you would otherwise need to use JavaScript, but it wasn't properly supported even in the browser I was using when I was making that website (Safari 6), so I was kind of forced to insert inline CSS from JavaScript to simulate that.
Even so, separating JavaScript and CSS that's used in all pages into separate files wouldn't be an easy task. To make the transparent SVGs on the homepage (the problem appears only because of the background image on the homepage) render properly in both Internet Explorer 11 and other modern browsers, I had to change quite a lot of CSS and even do some browser-sniffing in JavaScript (I gave up trying to make it render correctly in Internet Explorer <=10 and Opera <=14 and just deleted the background image in them).
I looked at your new phoneme-game page, and its behavior and the code behind it look a lot more like what I'd expect. Personally, I'd recommend you start working with server-side code and a database: both to serve up your data, and also to record user inputs-- then you could give stats like how many people go each answer right or wrong and so on.
Quote:Quote:I've literally copied a sample project that someone had working online, run it in development, and had it fail, and have zero idea at all why.Yeah, me too. I've tried to make a scientific calculator for Android by letting Duktape execute the JavaScript code identical to one in the web-app. Do I need to tell you how much tweaking I had to do to make it useful? First, I got a bunch of ReferenceErrors because "if (window)", which I've used quite a few times in the code, doesn't quite do what I thought it would do. Then, a bunch of errors related to the global variables not ending up initialized, because I made them get initialized only in button-click event handlers (seriously!). Then, when I finally got it to load without errors, it was very slow. But I managed to speed it up around 7 times just by minifying the JavaScript using jscompress. It's quite ironic that what made it slow weren't the terrible algorithms I've used (there is an algorithm to do something in linear time, but I was using an algorithm that runs in cubic time because it was easier to implement in JavaScript), but the incorrect usage of the framework.
I found my problem-- I was recording from a live mic, and when you initialize an audio context, it pops up a permission screen. Normally, that was enough to allow you access to the mic. Now, however, Chrome requires that whenever you create a new recorder, you need to do it in an event handler from user input, even if you already have permission to record.
That's a very good rule, and should be in place, but it took me quite a lot of failed attempts to figure out why the code wasn't working.