Skip to content

Iiab menu js#3

Open
psiie wants to merge 2 commits intoiiab:masterfrom
psiie:iiab-menu-js
Open

Iiab menu js#3
psiie wants to merge 2 commits intoiiab:masterfrom
psiie:iiab-menu-js

Conversation

@psiie
Copy link

@psiie psiie commented May 27, 2018

refactored to scope as much as possible. Wrapped entire script in an IIFE to scope functions & variables away from the window object. Should improve performance.

By using var calcHtmlLink = function() {} instead of function calcHtmlLink() {}, the function isn't created until it is needed, and can cleanup afterwords. Not only that, it is removed from global scope which when saturated degrades performance.

Wrapped the entire function in a (function() {})() for the same reason.

Also went ahead and made all if/else statements use curly braces. I am all for the shorthand, but for best compatibility, we should wrap them.

added var to some variables. When not declaring var, the js interpreter will elevate/hoist that variable to global scope. It does this as a way to ensure that the program will not crash.

darkenvy added 2 commits May 27, 2018 12:01
…IIFE to scope functions & variables away from the window object. Should improve performance
@georgejhunt georgejhunt mentioned this pull request Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant