diff --git src/wp-includes/class.wp-scripts.php src/wp-includes/class.wp-scripts.php
index 298eda7..1fc0eff 100644
--- src/wp-includes/class.wp-scripts.php
+++ src/wp-includes/class.wp-scripts.php
@@ -154,6 +154,7 @@ class WP_Scripts extends WP_Dependencies {
 			 * @param string $handle Script handle.
 			 */
 			$srce = apply_filters( 'script_loader_src', $src, $handle );
+
 			if ( $this->in_default_dir( $srce ) && ! $conditional ) {
 				$this->print_code .= $this->print_extra_script( $handle, false );
 				$this->concat .= "$handle,";
@@ -163,6 +164,7 @@ class WP_Scripts extends WP_Dependencies {
 				$this->ext_handles .= "$handle,";
 				$this->ext_version .= "$handle$ver";
 			}
+
 		}
 
 		$has_conditional_data = $conditional && $this->get_data( $handle, 'data' );
@@ -190,7 +192,16 @@ class WP_Scripts extends WP_Dependencies {
 		if ( ! $src )
 			return true;
 
-		$tag = "{$cond_before}<script type='text/javascript' src='$src'></script>\n{$cond_after}";
+		$before_handle = $this->print_inline_script( $handle, 'before', false );
+		if ( $before_handle ) {
+			$before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle );
+		}
+		$after_handle = $this->print_inline_script( $handle, 'after', false );
+		if ( $after_handle ) {
+			$after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle );
+		}
+
+		$tag = "{$cond_before}{$before_handle}<script type='text/javascript' src='$src'></script>\n{$after_handle}{$cond_after}";
 
 		/**
 		 * Filter the HTML script tag of an enqueued script.
@@ -213,6 +224,59 @@ class WP_Scripts extends WP_Dependencies {
 	}
 
 	/**
+	 * Add extra code to a registered script.
+	 *
+	 * @since 4.5.0
+	 *
+	 * @param string $handle   Name of the script to add the inline script to. Must be lowercase.
+	 * @param string $data     String containing the javascript to be added.
+	 * @param string $position Optional. Whether to add the inline script before the handle
+	 *                         or after. Default 'after'.
+	 *
+	 * @return bool True on success, false on failure.
+	 */
+	public function add_inline_script( $handle, $data, $position = 'after' ) {
+		if ( ! $data ) {
+			return false;
+		}
+
+		if ( 'after' !== $position ) {
+			$position = 'before';
+		}
+
+		$script   = (array) $this->get_data( $handle, $position );
+		$script[] = $data;
+
+		return $this->add_data( $handle, $position, $script );
+	}
+
+	/**
+	 * Print inline scripts registered for a specific handle.
+	 *
+	 * @param string $handle   Name of the script to add the inline script to. Must be lowercase.
+	 * @param string $position Optional. Whether to add the inline script before the handle
+	 *                         or after. Default 'after'.
+	 * @param bool $echo       Optional. Whether to echo the script instead of just returning it.
+	 *                         Default true.
+	 * @return string|bool Script on success, false otherwise.
+	 */
+	public function print_inline_script( $handle, $position = 'after', $echo = true ) {
+		$output = $this->get_data( $handle, $position );
+
+		if ( empty( $output ) ) {
+			return false;
+		}
+
+		$output = trim( implode( "\n", $output ), "\n" );
+
+		if ( $echo ) {
+			printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );
+		}
+
+		return $output;
+	}
+
+	/**
 	 * Localizes a script, only if the script has already been added
 	 *
 	 * @param string $handle
diff --git src/wp-includes/functions.wp-scripts.php src/wp-includes/functions.wp-scripts.php
index c83a9d1..6741e07 100644
--- src/wp-includes/functions.wp-scripts.php
+++ src/wp-includes/functions.wp-scripts.php
@@ -86,6 +86,36 @@ function wp_print_scripts( $handles = false ) {
 }
 
 /**
+ * Add extra code to a registered script.
+ *
+ * Code will only be added if the script in already in the queue.
+ * Accepts a string $data containing the Code. If two or more code blocks
+ * are added to the same script $handle, they will be printed in the order
+ * they were added, i.e. the latter added code can redeclare the previous.
+ *
+ * @since 4.5.0
+ *
+ * @see WP_Scripts::add_inline_script()
+ *
+ * @param string $handle   Name of the script to add the inline script to. Must be lowercase.
+ * @param string $data     String containing the javascript to be added.
+ * @param string $position Optional. Whether to add the inline script before the handle
+ *                         or after. Default 'after'.
+ * @return bool True on success, false on failure.
+ */
+function wp_add_inline_script( $handle, $data, $position = 'after' ) {
+	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
+
+	if ( false !== stripos( $data, '</script>' ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Do not pass script tags to wp_add_inline_script().' ), '4.5.0' );
+		$data = trim( preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) );
+	}
+
+	return wp_scripts()->add_inline_script( $handle, $data, $position );
+}
+
+
+/**
  * Register a new script.
  *
  * Registers a script to be linked later using the wp_enqueue_script() function.
diff --git tests/phpunit/tests/dependencies/scripts.php tests/phpunit/tests/dependencies/scripts.php
index 73680df..61b238e 100644
--- tests/phpunit/tests/dependencies/scripts.php
+++ tests/phpunit/tests/dependencies/scripts.php
@@ -166,4 +166,124 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase {
         $this->assertFalse( wp_register_script( 'duplicate-handler', 'http://example.com' ) );
     }
 
+	/**
+	 * @ticket 14853
+	 */
+	function test_wp_add_inline_script_returns_bool() {
+		$this->assertFalse( wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ) );
+		wp_enqueue_script( 'test-example', 'example.com', array(), null );
+		$this->assertTrue( wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ) );
+	}
+
+	/**
+	 * @ticket 14853
+	 */
+	function test_wp_add_inline_script_unknown_handle() {
+		$this->assertFalse( wp_add_inline_script( 'test-invalid', 'console.log("before");', 'before' ) );
+		$this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
+	}
+
+	/**
+	 * @ticket 14853
+	 */
+	function test_wp_add_inline_script_before() {
+		wp_enqueue_script( 'test-example', 'example.com', array(), null );
+		wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
+
+		$expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
+		$expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
+
+		$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
+	}
+
+	/**
+	 * @ticket 14853
+	 */
+	function test_wp_add_inline_script_after() {
+		wp_enqueue_script( 'test-example', 'example.com', array(), null );
+		wp_add_inline_script( 'test-example', 'console.log("after");' );
+
+		$expected = "<script type='text/javascript' src='http://example.com'></script>\n";
+		$expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
+
+		$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
+	}
+
+	/**
+	 * @ticket 14853
+	 */
+	function test_wp_add_inline_script_before_and_after() {
+		wp_enqueue_script( 'test-example', 'example.com', array(), null );
+		wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
+		wp_add_inline_script( 'test-example', 'console.log("after");' );
+
+		$expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
+		$expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
+		$expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
+
+		$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
+	}
+
+	/**
+	 * @ticket 14853
+	 */
+	function test_wp_add_inline_script_multiple() {
+		wp_enqueue_script( 'test-example', 'example.com', array(), null );
+		wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
+		wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
+		wp_add_inline_script( 'test-example', 'console.log("after");' );
+		wp_add_inline_script( 'test-example', 'console.log("after");' );
+
+		$expected = "<script type='text/javascript'>\nconsole.log(\"before\");\nconsole.log(\"before\");\n</script>\n";
+		$expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
+		$expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\nconsole.log(\"after\");\n</script>\n";
+
+		$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
+	}
+
+	/**
+	 * @ticket 14853
+	 */
+	function test_wp_add_inline_script_localized_data_is_added_first() {
+		wp_enqueue_script( 'test-example', 'example.com', array(), null );
+		wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) );
+		wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
+		wp_add_inline_script( 'test-example', 'console.log("after");' );
+
+		$expected = "<script type='text/javascript'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
+		$expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
+		$expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
+		$expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
+
+		$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
+	}
+
+	/**
+	 * @ticket 14853
+	 */
+	public function test_wp_add_inline_script_concat() {
+		global $wp_scripts;
+
+		$wp_scripts->do_concat = true;
+		$wp_scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/'); // Default dirs as in wp-includes/script-loader.php
+
+		$expected_localized = "<!--[if gte IE 9]>\n";
+		$expected_localized .= "<script type='text/javascript'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
+		$expected_localized .= "<![endif]-->\n";
+
+		$expected = "<!--[if gte IE 9]>\n";
+		$expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
+		$expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
+		$expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
+		$expected .= "<![endif]-->\n";
+
+		wp_enqueue_script( 'test-example', 'example.com', array(), null );
+		wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) );
+		wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
+		wp_add_inline_script( 'test-example', 'console.log("after");' );
+		wp_script_add_data( 'test-example', 'conditional', 'gte IE 9' );
+
+		$this->assertEquals( $expected_localized, get_echo( 'wp_print_scripts' ) );
+		$this->assertEquals( $expected, $wp_scripts->print_html );
+	}
 }
