Automattic / Automattic/page-optimize

Idea: Wrap the individual scripts inside concattenation with try...catch

Open
#54 0 comments 0 reactions 0 assignees View on GitHub
[Type] Enhancement
Dominant language
PHP
Stars
35
Forks
12
PR merge metrics
No merged PRs in 30d

Description

When using unconcattenated JS, websites can continue to function if a single script has an error. If now these scripts are concattenated, it can result in very random errors (and this makes this especially hard to debug!) because not only the single script is not fully executed but all other scripts in the same concattenated JS file (see for example https://github.com/Automattic/jetpack/pull/18187).

So I had this idea that we could wrap the since JS scripts in `try { ... } catch (e) {}` constructs. So instead of this:
```
script1;script2;script3
```
we'd have
```
try{ script1 } catch (e); try{ script2 } catch (e);try{ script3 } catch (e);
```

If now an error occurs in the script while executing it, it won't bring the whole cascade down but would drop out of the single try...catch block, thus not causing more failure.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no files, tests, or entry points. Start by locating the plugin's JavaScript concatenation path and comparing it with the unconcattenated path; done means each individual script is isolated so an execution error does not prevent later scripts from running.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php, wordpress
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.