{"id":21405392,"url":"https://github.com/karimsa/iife-pop","last_synced_at":"2026-05-08T13:08:20.480Z","repository":{"id":119887961,"uuid":"127973721","full_name":"karimsa/iife-pop","owner":"karimsa","description":"Remove IIFEs at compile-time.","archived":false,"fork":false,"pushed_at":"2019-02-15T16:35:11.000Z","size":257,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T21:03:58.170Z","etag":null,"topics":["babel","iife","javascript","minification","transpiler"],"latest_commit_sha":null,"homepage":"http://npmjs.org/iife-pop","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karimsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-03T22:02:50.000Z","updated_at":"2019-04-05T15:59:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"1f8e368b-f10d-4938-a156-1aaee30626c9","html_url":"https://github.com/karimsa/iife-pop","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fiife-pop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fiife-pop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fiife-pop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fiife-pop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karimsa","download_url":"https://codeload.github.com/karimsa/iife-pop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902293,"owners_count":20366259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","iife","javascript","minification","transpiler"],"created_at":"2024-11-22T16:25:12.002Z","updated_at":"2026-05-08T13:08:15.453Z","avatar_url":"https://github.com/karimsa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eiife-pop\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eRemove IIFE-s at compile-time.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href='https://semaphoreci.com/karimsaprojects/iife-pop'\u003e\n    \u003cimg src='https://semaphoreci.com/api/v1/projects/ab0094e9-cd40-44eb-9d47-624e5eddf269/2516511/badge.svg' alt='Build Status'\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Motivation\n\nThe purpose of this babel plugin is to be able to evaluate \u0026 remove the existence of\nan IIFE at compile-time where it is possible to do so. The idea is to simplify code as\nmuch as possible at compile-time so that optimizations such as constant-folding can actually\nreduce code even further than they currently do.\n\nAs an example, look at this code:\n\n```javascript\nconst myValue = (function (arg) {\n  switch (arg) {\n    case 'A':\n    return 0\n\n    case 'B':\n    return 1\n\n    case 'C':\n    return 2\n\n    default:\n    return 3\n  }\n}( 'some-value' ))\n```\n\nModern-day minifiers such as babel-minify and uglify-js are able to reduce this down to:\n\n```javascript\nconst myValue=function(a){return'A'===a?0:'B'===a?1:'C'===a?2:3}('some-value');\n```\n\nThough this saves quite a few bytes via mangling, constant folding is not able to take place\nbecause of the IIFE. If we replace the IIFE in the original code, it might look something like this:\n\n```javascript\nconst _arg = 'some-value'\nlet _returnValue\n\nswitch (_arg) {\n  case 'A':\n    _returnValue = 0\n    break\n\n  case 'B':\n    _returnValue = 1\n    break\n\n  case 'C':\n    _returnValue = 2\n    break\n\n  default:\n    _returnValue = 3\n    break\n}\n\nconst myValue = _arg\n```\n\nThe code is the same, just without an IIFE. This new code can be minified down to:\n\n```javascript\nconst myValue=3;\n```\n\nWhich saves a further 63 bytes in this case (~80%) - plus much less work for the runtime to do.\n\n## License\n\nLicensed under MIT license.\n\nCopyright (C) 2018-present Karim Alibhai.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarimsa%2Fiife-pop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarimsa%2Fiife-pop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarimsa%2Fiife-pop/lists"}