A magnifying glass held over a trail of footprints, one print enlarged under the lens
Trusted third parties3 min read

Can I run my own code on my site?

Yes, you can bring your own code. bernard checks it, and you approve it. The rule is simple: no code runs on your site unless it passes bernard’s checks and you publish it. This works on every bernard account. Your own code reaches visitors only when you publish it, and before you do, the summary of the change tells you the page has new code on it and what that code talks to.

The prompt

“My old site had an interactive calculator. Can it work here?”

Signed in, Get my prompt fills in your site for you. Otherwise press Copy and fill in the [bracketed] parts. First time? Connect your AI to bernard once: Use your own AI (opens in a new tab).

Most of what a site does needs no code of yours: bernard’s own menus, carousels and forms, and the outside tools it has checked. Some sites need more, such as a calculator or a quiz built for your business. bernard has no ready-made part for that, so your assistant can add code for it. bernard checks the code first, and nothing reaches your visitors until you publish. For everything your site already does without any code of yours, see What can my site do with JavaScript?. If what you want is an animation, start with bernard’s library: see How do I add an animation to my site?. Everything bernard checks is in Is it safe to let bernard add code to my site?.

How it works

  1. You ask for the interactive part, in your own words.
  2. Your assistant prepares the code, from your own project if you have one.
  3. bernard checks the code before it goes into your draft:
    • It must not load code from other websites, except libraries on bernard’s approved list.
    • It must talk only to the places it names.
    • It must not send anything until a visitor does something, such as pressing a button.
    • It must not use tricks to recognise or follow your visitors.
  4. If the code fails a check, bernard does not put it on your page. Your assistant fixes the code and tries again. If code on your site fails the checks three times in 24 hours, it stops and tells you: “I could not make this pass bernard’s checks yet. bernard will look at it overnight.” Then it finishes the rest of your request without it.
  5. If the code passes, it goes into your draft. Look at the pages in the preview first.
  6. Before you publish, the summary of the change tells you what the code talks to. For most code it says “This page has new code on it. It talks to nothing outside your site.” If it names a place, that is where the code sends things, such as your own booking server.
  7. You publish it like any other change. Nothing reaches your visitors before that.

Publish only if you trust what the code does. If you are not sure, ask your assistant to explain it in plain words first.

What stays bernard’s

Your pages stay bernard pages. Your menus, the cookie choices your visitors make and your editing all keep working, and the code only runs inside the boxes it was placed in. If bernard moves your site again later, it puts the boxes back by itself.

Taking it off

Ask your assistant to remove the code, then publish. Your visitors stop getting it when that publish goes live. Putting back an earlier version of your site does not take the code off: ask your assistant to remove it, then publish.

Questions people ask

Who decides whether the code goes live?
You do. No code runs on your site unless it passes bernard’s checks and you publish it. The code goes into your draft, and you publish it like any other change. The publish is your approval. Before you publish, the summary of the change says the page has new code on it and what that code talks to.
What does bernard check?
bernard checks that the code does not load code from other websites, except libraries on bernard’s approved list. It checks that the code talks only to the places it names. It checks that the code does not send anything until a visitor does something, such as pressing a button. And it checks that the code does not use tricks to recognise or follow your visitors. If the code fails a check, bernard does not put it on your page.
Can I change my mind?
Yes. Ask your assistant to take the code off, then publish. Until you publish, nothing changes for your visitors, so you can look at the draft before you approve the change.
Does my site still look like my site if the code fails?
Yes. Every piece of your own code sits inside a box on a normal bernard page. If the code does not load, visitors see the page as it is, and you can still edit the words around it.
PageSpeed says my code files should be cached for longer. Is something wrong?
No. bernard keeps your own code files in a visitor’s browser for one hour on purpose. If you take the code off, it then stops running for returning visitors within the hour, instead of lingering for a year. PageSpeed lists those files under efficient cache lifetimes, and that is expected. Files that bernard names after their contents, such as most of your photos, fonts and stylesheets, are cached for a year, because their contents can never change under that name.
Is this on for everyone?
Yes. Every bernard account can add its own code this way. The same checks apply to everyone, and nothing reaches your visitors until you publish and approve the change. Animations from bernard’s library work on every site too.

Next