New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move functions F2-F9 & A2-A9 outside conditional #497

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@robertjlooby
Contributor

robertjlooby commented Feb 2, 2016

Using a function statement inside a conditional is non-standard (most browers other than Firefox will declare the function anyways). Since the only point of having these inside the conditional seems to be to prevent them from being redefined to the same thing if Runtime.js is included twice on the same page, it seems safe to move them out from the conditional.

The benefit to doing this is that it allows the Closure Compiler to be used on the generated elm.js (at least in WHITESPACE_ONLY and possibly on SIMPLE_OPTIMIZATIONS). A simple "Hello World" app:

module Main (..) where

import Graphics.Element exposing (show)


main =
    show "Hello World!"

When compiled is 147K.

Minimized on WHITESPACE_ONLY it is 96K (and works fine).

Minimized on SIMPLE_OPTIMIZATIONS is 61K (and works fine).

On a somewhat larger project of mine that compiles to 562K, making this change also allows WHITESPACE_ONLY compilation to 292K (works) and SIMPLE_OPTIMIZATIONS compilation to 202K (also works).

It's possible there's something I'm missing, but I don't think there's any downside to moving these outside the conditional.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Apr 28, 2016

Member

I'm not sure. It is going to just work different in the next release such that Closure Compiler has a much easier time with things. I've also verified that everything works with simple optimizations in the new version of things.

Member

evancz commented Apr 28, 2016

I'm not sure. It is going to just work different in the next release such that Closure Compiler has a much easier time with things. I've also verified that everything works with simple optimizations in the new version of things.

@evancz evancz closed this Apr 28, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment