kotlin for javascript

Example 2

buildscript {
    ext {
        kotlin_version = "1.3.11"
    }
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
    }
}

apply plugin: "kotlin2js"
apply plugin: "kotlin-dce-js"

repositories {
    mavenCentral()
}

dependencies {
    compile("org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version")
}

defaultTasks "ko4js"
assemble.dependsOn runDceKotlinJs

build.doLast {
    configurations.compile.each { File file ->
        copy {
            includeEmptyDirs = false

            from zipTree(file.absolutePath)
            into "${projectDir}/js"
            include { fileTreeElement ->
                def path = fileTreeElement.path
                path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
            }
        }
    }
}

//Note that if your function has parameters, its name will be mangled, so the mangled name should be used in the keep directive.
runDceKotlinJs.keep "ko4js.okoko.log", "ko4js.okoko.jtext_wn2jw4\$"

task uglifyjs(type: Exec) {
    commandLine "uglifyjs", "build/kotlin-js-min/main/kotlin.js", "build/kotlin-js-min/main/ko4js.js", "-c","-m", "-o", "js/ko4js.core.js"
    // commandLine "uglifyjs", "build/kotlin-js-min/main/kotlin.js", "build/kotlin-js-min/main/ko4js.js", "-b", "-o", "js/ko4js.core.js"
}

task ko4js {
    dependsOn build, uglifyjs, runDceKotlinJs
    uglifyjs.mustRunAfter runDceKotlinJs
}

compileKotlin2Js {
    kotlinOptions.outputFile = "${projectDir}/js/ko4js.js"
    kotlinOptions.moduleKind = "plain"
    kotlinOptions.sourceMap = false
    kotlinOptions.sourceMapEmbedSources = "never"
    kotlinOptions.metaInfo = false
}

task wrapper(type: Wrapper,overwrite: true) {
    gradleVersion = "5.0"
    distributionType = Wrapper.DistributionType.ALL
}
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cloud.ibinti.com/file/ko4js/ko4js.core.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    ko4js.okoko.jtext_wn2jw4$("p","Thank You, Sir!")
  });
  ko4js.okoko.jtext_wn2jw4$("p","If you click on me, You will be mesmerized.")
});
</script>
</head>
<body>

<p>If you click on me, You will be blessed.</p>

</body>
</html>