Front-end code for WordPress sites: AJAX forms and live search, calling the REST API with fetch(), replacing old jQuery code, loading scripts with async and defer, and TypeScript for block development.
useEffect in custom blocks: fetch data, debounce input, clean up The edit function of a block is a React component. When it needs data from the server, for example the title of a feed whose URL the editor typed, the request belongs in useEffect: it runs after rendering, can depend on attributes, and can clean…
A simple example of AJAX for an HTML form As they say, a developer does not live by WordPress alone. Today I will show an example of AJAX for a simple landing page built without the most popular CMS. The form sends an email without a page reload.
Block free email providers in a contact form Sometimes site owners want the email addresses of official company representatives who register or send requests on their sites, not personal Gmail or Yahoo addresses. In this case the email field of the contact form has to be checked.