Hotwire Discussion

Stimulus controllers incompatible with Opera Mini?

Bit of a general question without specifics, sorry, but Opera mini is hard to troubleshoot.

I’m refactoring a site with Sprockets and a thicket of jquery snippets to use Stimulus controllers instead. I’m bundling with Vite/Rollup with the vite legacy plugin (i.e. Babel with browserslist etc), and the legacy bundle is output correctly, but hardly anything works on Opera Mini. I suspect I’m missing a polyfill or something, but I’ve tried the Stimulus polyfill package, and there’s no help there.

I had an issue or two getting IE11 to work, but nothing like this. Anyway, I don’t intend to make IE work any more due to being EOL, while Opera Mini is used by 100 million users in Africa alone, so it’d be nice to get it to kinda work.

The reason I’m suspecting Stimulus and not my code within the controllers themselves is the fact that not even a click action that uses classList toggle works, it’s that basic.

What’s even more annoying is that I firmly believe in progressive enhancement to the point that the site works quite well with javascript disabled completely, I have noscript replacements even for some of my javascript filtering controllers. But badly working javascript is so much worse than no javascript at all.

Has anyone experienced this with Stimulus?

What hardware are you testing on? It might be helpful to point to an example.

I’m using a couple of different Android devices, and I’ve tried almost every browser on the planet. Only Opera Mini exhibits this particular issue. But I’ve been digging some more, and I think this might be a bug in ViteJS (or upstream in SystemJS (which is used by Vite for legacy bundles)) and might not be related to Stimulus at all. I’m pretty sure SystemJS isn’t initialized properly in Opera Mini, so none of the legacy code loads. I’ll update this thread once I know more. Sorry for the lack of specifics! (It’s just really hard to troubleshoot Opera Mini.)

Okay, so it seems some code triggers an error in IE that’s solved by polyfilling webcomponents. I thought sure, I can use a polyfill for my legacy javascript bundle. But it’s this polyfill that breaks Opera Mini completely. So yeah. Not a problem with Stimulus per se, but reliance on newer web technologies that are hard to polyfill creates this issue.