ghinda / jotted

Environment for showcasing HTML, CSS and JavaScript, with editable source.
https://ghinda.net/jotted/
MIT License
491 stars 36 forks source link

Fail-proof reload. #23

Closed armoucar closed 7 years ago

armoucar commented 7 years ago

Hi,

I don't know why but, intermittently, Jotted is not able to load the Result tab. It happens few times and to emulate this error, I have to keep reloading my browser until I get it. I was trying to make my own solution, something like check the iframe content and if things I want are not there, force jotted to reload. Thing is the content is cached and because of cache I'm not able to:

jotted.change({ target: textAreaIWantToReload })

Oh, I use CodeMirrorPlugin.

Thanks :)

ghinda commented 7 years ago

Can you make a http://jsbin.com/? Are you using external files or inline strings?

armoucar commented 7 years ago

I'm using external files. I'm not sure how I am going to use external files with jsbin.

I've just tested the website's example and it happens locally on my computer. To emulate it, you'll have to reload quite few times until you maybe get it. Make sure all the time you reload your browser you do it cleaning the cache. The image below exemplifies the problem.

image

Thanks!

armoucar commented 7 years ago

It also happens in the homepage. I couldn't reproduce it on Firefox. I'm using Chrome.

image

armoucar commented 7 years ago

So, this isn't a solution for the problem I brought here, but it enables Jotted's users to pass on a parameter that is already defined inside Jotted's code.

With this, I'll be able to do what I described, create an in-house solution to make sure that Jotted loads everything all the time.

I'll spend time on this problem after to find a proper solution, for the moment, this is what I can do to solve the problem I have here in the company.

Many thanks!

armoucar commented 7 years ago

You're not going to accept it, are you? 😂

@ghinda

ghinda commented 7 years ago

Thanks for looking into this. I noticed it myself a couple of times but couldn't replicate it. My best guess is that Chrome has some issues with srcdoc, used on the iframe.

To work around it, I've changed the renderer to use document.write instead of srcdoc.

I released a new version with this and some other fixes as 1.4.3. Please try it out and let me know if the issue still shows up.

I used forceRender as a sort-of hack only for the Play plugin, so I wouldn't want to use it more than that. Ultimately I would like to remove it completely. Thanks for taking a stab at it! :beers:

armoucar commented 7 years ago

I've done tests and couldn't get the rendering part failing. I think this is it, thanks for the fix and for keeping the project clean not accepting my workaround code. 😄

ghinda commented 7 years ago

Awesome! I didn't merge it just because it is pretty much my hack, and I'm hoping to refactor that part.

But any pull requests are very very welcome! :beers: