JavaScript Chat Summary: May 2nd

The first-ever JavaScriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. Chat took place today (agenda, Slack archive). Below is a summary of the conversation:

Meeting Goals

  • Identify common requirements and ensure consistency between individuals and projects making heavy use of JavaScript in coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress.
  • Discuss what must be provided as the “base” APIs to provide similar functionality in the browser as what’s available in PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20
  • Decide patterns and tools / frameworks to accommodate modern and future requirements
  • Understand how plugins and themes plan to use the browser context to avoid conflicts and incompatibilities

Tickets

The following tickets were discussed, chosen as having most immediate impact:

Actions and Filters

  • An effort to mirror PHP extensibility in the browser by providing hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. to transform data and take action in response to specific events
  • Consistency with PHP equivalents can improve developer experience by providing familiar tools, but we should be sure that the paradigms apply well across the languages
  • Worries
    • Are there special considerations for asynchronous coding patterns prevalent in JavaScript?
    • Do we first need to better outline how we expect data to be structured and managed in the client before deciding on transformation APIs?
  • Alternatives
    • Hyper.is extensions apply themselves as decorations, or intervene as middlewares in the application’s data flow
    • Reactive programming styles with observables (spec proposal, RxJS)
  • A side-exploration of data modeling requirements was raised, with a general desire to encapsulate state (perhaps in a single store) and provide options to inspect data and apply modifications at specific entry points. This should be able to be adopted incrementally, rather than as a full rewrite.

Date Handling

  • Ticketticket Created for both bug reports and feature development on the bug tracker. patchpatch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing. provides basic date formatting and localization on a wp.date global, matching those available in PHP (format, date, gmdate, date_i18n)
  • Non-controversial and ideally merged soon
  • Current proposed patch uses Moment.js, but interface does not bind us to it
  • We may want to consider future compatibility with overlapping browser APIs, such as DateTimeFormat. However, these implementations are browser-specific and compatibility with the date format site setting can’t always be guaranteed.

Internationalization

  • We need gettext support in the browser
  • How do we makemake A collection of P2 blogs at make.wordpress.org, which are the home to a number of contributor groups, including core development (make/core, formerly "wpdevel"), the UI working group (make/ui), translators (make/polyglots), the theme reviewers (make/themes), resources for plugin authors (make/plugins), and the accessibility working group (make/accessibility). strings available in the browser
    • By passing strings in HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers. via wp_localize_script?
    • Asynchronously through REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/. endpoints?
    • Probably best to stick with simpler approach to start (passed in HTML)
  • Need to consider build tools to extract strings from JavaScript
    • PHP solutions may not be future compatible with the frequently changing JavaScript language specification. This is a solved problem with JavaScript parsers tending to follow closely to the bleeding edgebleeding edge The latest revision of the software, generally in development and often unstable. Also known as trunk..

General

Please join us when we meet again next week at the same time. In the meantime, there are many tickets in the TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. JavaScript focus that can use help! https://core.trac.wordpress.org/focus/javascript

#javascript, #summary