NotHereToPlayGames Posted May 18, 2023 Author Share Posted May 18, 2023 5 minutes ago, Anbima said: What is the easiest and best way to include polyfills? I use Tampermonkey. Link to comment Share on other sites More sharing options...
Anbima Posted May 18, 2023 Share Posted May 18, 2023 32 minutes ago, NotHereToPlayGames said: I use Tampermonkey. Is there a "leaner" option which only embeds polyfills? Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 18, 2023 Author Share Posted May 18, 2023 17 minutes ago, Anbima said: Is there a "leaner" option which only embeds polyfills? Proxomitron or Proximodo or Proxydomo. Link to comment Share on other sites More sharing options...
rereser Posted May 19, 2023 Share Posted May 19, 2023 ECMAScript proposal “Change Array by copy”: four new non-destructive Array methods https://2ality.com/2022/04/change-array-by-copy.html four new polyfills are on the page. all implemented in chrome 110+ not sure we need them as i have no way to test. Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 19, 2023 Author Share Posted May 19, 2023 6 minutes ago, rereser said: https://2ality.com/2022/04/change-array-by-copy.html four new polyfills are on the page. Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 20, 2023 Author Share Posted May 20, 2023 I'm finding that having "too many" polyfill injections cause more problems then they solve (breaks Sedecordle, breaks MS Teams, just the first two I've found). For now, I just keep my list of polyfills disabled by default then enable them when needed as opposed to just injecting them all "just in case" they might be needed. Technically, I've yet to encounter these on any web site I ever visit. Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 20, 2023 Author Share Posted May 20, 2023 1 hour ago, NotHereToPlayGames said: (breaks Sedecordle, breaks MS Teams, just the first two I've found) In both cases, it was only this polyfill that broke the page -- if (!Array.prototype.findLastIndex) { Array.prototype.findLastIndex = function (callback, thisArg) { for (let i = this.length - 1; i >= 0; i--) { if (callback.call(thisArg, this, i, this)) return i; } return -1; }; } Link to comment Share on other sites More sharing options...
rereser Posted May 20, 2023 Share Posted May 20, 2023 (edited) https://msfn.org/board/topic/184624-arcticfoxienotheretoplaygames-360chrome-v1352036-rebuild-1/?do=findComment&comment=1245462 https://msfn.org/board/topic/184624-arcticfoxienotheretoplaygames-360chrome-v1352036-rebuild-1/?do=findComment&comment=1245468 https://msfn.org/board/topic/184624-arcticfoxienotheretoplaygames-360chrome-v1352036-rebuild-1/?do=findComment&comment=1245522 my posts for "Array.prototype.findLastIndex" , "Array.prototype.at" and "Array.prototype.findLast" polyfills have been edited. got it wrong the first time ... source : https://github.com/behnammodi/polyfill/blob/master/array.polyfill.js only the first three that i posted are needed to pass the tests on https://developer.mozilla.org/ all other arrays already work in 13.5.2036. no tests available yet for the latest four very new ones. Edited May 20, 2023 by rereser 1 Link to comment Share on other sites More sharing options...
rereser Posted May 20, 2023 Share Posted May 20, 2023 (edited) test : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at chrome 92 : https://caniuse.com/mdn-javascript_builtins_string_at // ==UserScript== // @name Inject String.at Polyfill // @version 0.0.1 // @match *://*/* // @run-at document-start // @grant none // ==/UserScript== if (!String.prototype.at) { Object.defineProperty(String.prototype, "at", { value: function (n) { // ToInteger() abstract op n = Math.trunc(n) || 0; // Allow negative indexing from the end if (n < 0) n += this.length; // OOB access is guaranteed to return undefined if (n < 0 || n >= this.length) return undefined; // Otherwise, this is just normal property access return this[n]; }, writable: true, enumerable: false, configurable: true }); } Edited May 20, 2023 by rereser 1 Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 20, 2023 Author Share Posted May 20, 2023 6 hours ago, rereser said: my posts for "Array.prototype.findLastIndex" , "Array.prototype.at" and "Array.prototype.findLast" polyfills have been edited. Awesome, thanks! I did miss the edit and also somehow missed the findLast. I can now keep all enabled without any page breaks. Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 20, 2023 Author Share Posted May 20, 2023 6 hours ago, rereser said: no tests available yet for the latest four very new ones. I'm opting for this polyfill but do have the four "smaller" ones included-but-disabled in my Tampermonkey set of userscripts. Won't really know the best option until we can find an example web site or two. Link to comment Share on other sites More sharing options...
rereser Posted May 20, 2023 Share Posted May 20, 2023 the last new four are in chrome 110. the link you posted is a replacement for those four ? a lot more lines ... Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 20, 2023 Author Share Posted May 20, 2023 The 2ality post specifically states "this blog post only demonstrates the new methods with Arrays, but they are also available for Typed Arrays". Typed Arrays are - Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array BigInt64Array BigUint64Array This (same link as earlier post) polyfill should work for Arrays and Typed Arrays. Link to comment Share on other sites More sharing options...
rereser Posted May 20, 2023 Share Posted May 20, 2023 (edited) understand and thank you for the link. had a look at the readme.md , makes more sense now. added that polyfill and disabled the four others. will see what this does in the future. it does not slow down the browser so that is good. Edited May 20, 2023 by rereser Link to comment Share on other sites More sharing options...
NotHereToPlayGames Posted May 20, 2023 Author Share Posted May 20, 2023 45 minutes ago, rereser said: it does not slow down the browser so that is good. Agreed. I'm just keeping my full list of polyfills enabled since I'm seeing no more page breaks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now