Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="container">
  <div class="textarea-container">
    <textarea placeholder="Enter review to classify"></textarea>
    <div class="classification-result"></div>
  <div class="buttons">
    <div class="model tflite">
      <div class="btn disabled">TFLite Movie Review</div>
      <div class="result"></div>


                body {
  font-family: Arial, Helvetica, sans-serif;
  padding: 20px;

.container {
  display: flex;

textarea {
  border: 1px solid #999;
  border-radius: 4px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  height: 60px;
  padding: 8px;
  width: 500px;

.container {
  display: flex;

.buttons {
  margin-left: 20px;
  margin-top: -10px;

.model {
  display: flex;
  align-items: center;

.result {
  margin-left: 20px;

.btn {
  border: 1px solid #888;
  cursor: pointer;
  width: 200px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;

.btn:hover {
  background-color: #eee;

.classification-result {
  margin-top: 6px;
  color: #888;

.classification-result .label {
  display: inline-block;
  width: 140px;
  color: black;

.classification-result .sentiment.true {
  color: #00AA00;


                const textarea = document.querySelector("textarea");
const classificationResult = document.querySelector(".classification-result");
let lastModel;
let lastClassName;
let warmedUp = false;

  async () =>
    await tfTask.NLClassification.CustomModel.TFLite.load({
      model: ""

async function setupButton(className, modelCreateFn, needWarmup) {
    .querySelector(`.model.${className} .btn`)
  const resultEle = document.querySelector(`.model.${className} .result`);
    .querySelector(`.model.${className} .btn`)
    .addEventListener("click", async () => {
      let model;
      // Create the model when user clicks on a button.
      if (lastClassName !== className) {
        // Clean up the previous model if existed.
        if (lastModel) {
        // Create the new model and save it.
        resultEle.textContent = "Loading...";
        model = await modelCreateFn();
        lastModel = model;
        lastClassName = className;
      // Reuse the model if user clicks on the same button.
      else {
        model = lastModel;

      // Warm up if needed.
      if (needWarmup && !warmedUp) {
        await model.predict(textarea.value);
        warmedUp = true;

      // Run inference and update result.
      const start =;
      const result = await model.predict(textarea.value);
      const latency = - start;
      resultEle.textContent = `Latency: ${latency}ms`;

function renderResult(result) {
  const strResult = => {
    return `${cls.className}: ${cls.score.toFixed(3)}`;
  }).join(', ');
  classificationResult.innerHTML = strResult;